package 三六零机试;

import java.util.Scanner;

public class ThreeSixZero第三题 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int n1 = sc.nextInt();
            int[] a = new int[n1];
            for (int i = 0; i < n1; i++) {
                a[i] = sc.nextInt();
            }
            int n2 = sc.nextInt();
            int[] b = new int[n2];
            for (int i = 0; i < n2; i++) {
                b[i] = sc.nextInt();
            }
            func(n1, a, n2, b);

        }
        sc.close();
    }

    private static void func(int n1, int[] a, int n2, int[] b) {
        int suma = getSum(n1, a);
        int sumb = getSum(n2, b);
        int res = Math.abs(suma - sumb);
        for (int i = 0; i < n1; i++) {
            for (int j = 0; j < n2; j++) {
                swap(a, b, i, j);
                for (int k = 0; k < n1; k++) {
                    for (int l = 0; l < n2; l++) {
                        if (k != i && l != j) {
                            swap(a, b, k, l);
                            res = Math.min(Math.abs(getSum(n1, a) - getSum(n2, b)), res);
                        }
                    }
                }
            }
        }
        System.out.println(res);
    }

    private static void swap(int[] a, int[] b, int i, int j) {
        a[i] = a[i] ^ b[j];
        b[j] = a[i] ^ b[j];
        a[i] = a[i] ^ b[j];
    }

    private static int getSum(int n1, int[] a) {
        int sum = 0;
        for (int i = 0; i < n1; i++) {
            sum += a[i];
        }
        return sum;
    }
}
